<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        var msg="消息"
        window.onload=function(){
            var h1Dom=document.getElementById("h1");
            var inputDom=document.getElementById('input');
            h1Dom.innerHTML=msg;
            inputDom.value=msg;
            inputDom.oninput=function(){
                msg=inputDom.value;
                h1Dom.innerHTML=msg;
            }
        }
    </script>
</head>
<body>
    <h1 id="h1"></h1>
    <input type="text" id="input">
</body>
</html>